import Q from 'q'
import axios from 'axios'
import envFuncs from '@/config/base'
let env = envFuncs.getParams()
import { S, U, getRequestId, mapField } from '../../lib/backend'

let CRM_API_HOST = env.CRM_API_HOST

export default {
  getNewCustomList ({rootState}, info) {
    // let CRM_API_HOST = ' http://rap.taobao.org/mockjsdata/18476'
    let url = CRM_API_HOST + '/sites/' + rootState.app.site_id + '/users/' + rootState.app.token + '/new_custom_list' + '?' + U(info || {}, false)
    // let url = 'http://rap2api.taobao.org/app/mock/2717/GET//example/1514357201480'
    return axios.get(url)
  },
  getRollList ({ rootState }, info) {
    // let CRM_API_HOST = ' http://rap.taobao.org/mockjsdata/18476'
    let url = CRM_API_HOST + '/users/' + rootState.app.token + '/income_customs' + '?' + U(info || {}, false)
    // let url = 'http://rap2api.taobao.org/app/mock/2717/GET/user/%7Btoken%7D/income_customs' + '?' + U(info || {}, false)
    return axios.get(url)
  },
  getIntelClientSeaCustoms ({ rootState }, info) {
    // let CRM_API_HOST = ' http://rap.taobao.org/mockjsdata/18476'
    let url = CRM_API_HOST + '/users/' + rootState.app.token + '/high_seas' + '?' + U(info || {}, false)
    // let url = 'http://rap2api.taobao.org/app/mock/2717/GET//example/1514357201480'
    return axios.get(url)
  },
  robIntelSeaCustom ({ rootState }, info) {
    // let CRM_API_HOST = ' http://rap.taobao.org/mockjsdata/18476'
    let url = CRM_API_HOST + '/users/' + rootState.app.token + '/high_seas/rob'
    // let url = 'http://rap2api.taobao.org/app/mock/2717/GET//example/1514357201480'
    return axios.post(url, info)
  },
  saveCustomRemindTimer({rootState}, info) {
    // let CRM_API_HOST = ' http://rap.taobao.org/mockjsdata/18476'
    let url = CRM_API_HOST + '/sites/' + rootState.app.site_id + '/users/' + rootState.app.token + '/timer_message_time'
    // let url = 'http://rap2api.taobao.org/app/mock/2717/GET//example/1514357201480'
    return axios.post(url, info)
  }
}
